﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using System.Net;
using System.Net.WebSockets;   

namespace WabSocketServer_Net
{
    class Program
    {
        private Task context;

        static void Main(string[] args)
        {

            //创建HttpListener类，并启动监听：
            var listener = new HttpListener();
            listener.Prefixes.Add("http://10.10.13.140:8080/");
            listener.Start();

            ////等待连接
            //var context = listener.GetContext();

          

            ////开始异步接收数据     
            //var wsdata = await ws.ReceiveAsync(abuf, cancel);
            //Console.WriteLine(wsdata.Count);
            //byte[] bRec = new byte[wsdata.Count];
            //Array.Copy(buf, bRec, wsdata.Count);
            //Console.WriteLine(Encoding.Default.GetString(bRec));


            ////注意，使用完，记得释放，不然会有内存泄漏
            //ws.Dispose();
        }

        async void AcceptWebSocketAsync()
        {
            ////接收websocket
            //var wsContext = await context.AcceptWebSocketAsync(null);
            //var ws = wsContext.WebSocket;
            //Console.WriteLine("WebSocket connect");
        }
    }
}
